catvm.memory.Plugin={};
var Plugin = function Plugin() {
    //如果不能new  要抛出一个错误
    throw new TypeError("Illegal constructor");
}//构造函数
catvm.safefunction(Plugin); //tostring 保护
//内存存储  为了保护非全局函数
catvm.memory.Plugin.iterator = function values() {
    debugger;
    return {
        next:function () {
            if(this.index_ == undefined){
                this.index_=0;
            }
            var temp=this.self_[this.index_];
            this.index_++;
            if(temp!=undefined){
                return {done:false,falvalue:temp};
            }else {
                return {done:true,falvalue:temp};
            }
        },
        self_:this
    }

};catvm.safefunction(catvm.memory.Plugin.iterator); //tostring 保护

//设置原型链上显示的名字***************************************************************************
Object.defineProperties(Plugin.prototype, {
    [Symbol.toStringTag]: {
        value: "Plugin",
        configurable: true
    },
    [Symbol.iterator]: {
        value: catvm.memory.Plugin.iterator,
        configurable: true
    }
});

//该环境下的属性和方法***************************************************************************
Plugin.prototype.description ='';
Plugin.prototype.filename='';
Plugin.prototype.name='';
Plugin.prototype.length=0;
Plugin.prototype.item=function item(i) {
    return this[i]
};catvm.safefunction(Plugin.prototype.item);
Plugin.prototype.namedItem=function namedItem(i) {
    return this[i]
};catvm.safefunction(Plugin.prototype.namedItem);


//new出来的实例在没有继承的情况下获取是报错情况
for (var pluginKey in Plugin.prototype) {
    if(typeof(Plugin.prototype[pluginKey])!='function'){
        Plugin.prototype.__defineGetter__(pluginKey,function () {
            throw new TypeError("Illegal constructor");
        })
    }
}


//catvm.memory.Plugin.new({description:"npAlisSOLogin Plugin",filename:"lnpalissologin.dll" ,name:"AlissOLogin plugin",MimeTypes:[{description: "AliSSOLogin " ,suffixes: "AlisSOLogin" ,type: "application/npalissologin." },{description: "AlissoLogin1" ,suffixes: "AlissoLogin" ,type: "application1/npalissologin"}]})

//用自己的方式new出来实例
catvm.memory.Plugin.new=function (data) {
    var plugin={};
    if(data !=undefined){
        plugin.description=data.description;
        plugin.filename = data.filename;
        plugin.name=data.name;
        if(data.MimeTypes !=undefined){
            for (let i = 0; i < data.MimeTypes.length; i++) {
                var mimeTypedata = data.MimeTypes[i];
                var mimeType=catvm.memory.MimeType.new(mimeTypedata,plugin);
                plugin[i]=mimeType;
                // plugin[mimeType.length]=mimeType
                Object.defineProperty(plugin,mimeType.type,{
                    value:mimeType
                })
            }
            plugin.length=data.MimeTypes.length;
        }
    }
    plugin.__proto__=Plugin.prototype;
    return plugin
}

